package com.likou;

/**
 * Author: 陈桂明
 * Date: 2025/9/2 16:13
 * Description: q240
 */
public class q240 {
    public static void main(String[] args) {

    }

    public boolean searchMatrix(int[][] matrix, int target) {
        int m = matrix.length;
        int n = matrix[0].length;

        for (int i = 0; i < m; i++) {
            int left = 0;
            int right = n - 1;
            while (left <= right) {
                int num = matrix[i][(left + right) / 2];
                if (target > num) {
                    left = (left + right) / 2 + 1;
                } else {
                    right = (left + right) / 2 - 1;
                }

                if (target == num) {
                    return true;
                }
            }
        }

        return false;
    }
}
